/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.iasd.youthshelter.datacore;

import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import org.openide.modules.ModuleInstall;

public class Installer extends ModuleInstall {

    @Override
    public void restored() {
//        EntityManager entityManager = Persistence.createEntityManagerFactory("YouthShelterH2").createEntityManager();
//        entityManager.getTransaction().begin();
//        // Check for database existence and create it if needed.
//        try {
//            entityManager.createNativeQuery("SELECT COUNT(*) FROM pathfinder;").getSingleResult();
//        } catch(Exception ex) {
//            StringBuilder strBuilder = new StringBuilder();
//            BufferedReader reader = new BufferedReader(getClass().getClassLoader().getResourceAsStream("pt/iasd/youthshelter/datacore/create.sql"));
//            entityManager.createNativeQuery(null).executeUpdate();
//        }
//        entityManager.getTransaction().commit();
//        entityManager.close();
//        entityManager = null;
    }

    @Override
    public void close() {
    }
}
